﻿#ifndef MYTHREAD_H
#define MYTHREAD_H
#include <QThread>

class MyServer;
class MySocket;

class UdpAssistant;
class TcpServerAssistant;
class TcpAssistant;

//Socket创建辅助类
class SocketHelper:public QObject
{
    Q_OBJECT
public:
    explicit SocketHelper(QObject *parent = nullptr);

    MyServer* myserver;

    bool HexStringToByte(QString &str,QByteArray &ba);      //16进制字符串转字节数组
    void ByteToHexString(QString &str,QByteArray &ba);      //字节数组转16进制字符串
    QString Get_LocalIp();                                  //获取本地IP


public slots:
    void CreateSocket(qintptr socketDescriptor,int index);  //创建socket

signals:
    void Create(qintptr socketDescriptor,int index);        //创建
    void AddList(MySocket* tcpsocket,int index);            //添加信息
    void RemoveList(MySocket* tcpsocket);                   //移除信息


};

//子线程类
class MyThread : public QThread
{
    Q_OBJECT
public:
    explicit  MyThread(QObject *parent);
    ~MyThread() override;
public:
    MyServer*      myserver;
    SocketHelper* sockethelper;
    int ThreadLoad;
    void run() override;
};

#endif // MYTHREAD_H
